<template>
  <div style="margin-top:12px;flex:1">
    <search-filed :searchList="[...searchListArr, ...unFieldList]" :selectField="{...resumeField, ...unField}" @clear="clearSearch" @close="closeOneField"/>
    <!-- {{selectedRows}}
    、、、、、、、、、、、、、、、、、、、、、、、、、
    {{filterBtn(operateBtn, selectedRows, recordBtn)}} -->
    <a-table size="middle" class="CandidateTable" style="padding: 0 12px" :scroll="{x: true}" :rowKey="record=>record.id" :columns="[...columns, ...fieldsTmp]" :dataSource="data" :rowSelection="isPending ? null : {selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" :rowClassName="setRowClassName" :pagination="pagination" :loading="loading">
      <template slot="title">
        <TableOperate ref="TableOperate" :refresh="true" :valueFileds="valueFileds"
        :dateName="`${isPending ? '上传' : $t('candidateApplication.recommend')}${$t('common.date')}`" :operateBtn="selectedRowKeys.length > 0 && operateBtnOP.length > 0 ? operateBtnOP : null"
        :deliveryDate="deliveryDateArr" :searchList="searchListArr" searchTitle="姓名" :dateData="dateData"
        @chooseDeliveryDate="chooseDeliveryDate" @searchFormValue="searchFormValue" @batchOperation="(id)=>batchOperation(id, selectedRowKeys.join(','))"
        />
      </template>
      <!-- 名称 军工可进行合适、不合适、待定、归档等操作, 猎头 修改-->
      <template slot="name" slot-scope="text, record">
        <p :class="`updateText ${!isPending ? 'blue_hover': ''}`" :record="record" @click="!isPending && editResume(record)">{{text}}</p>
        <p class="update">
          <!-- 待推荐推荐用户  && record.status !== 'update'-->
          <!-- <span v-if="isPending && vendorPartnerStatus === 'Y'" src="javascript:;" @click="recommedRecom(true, record)">推荐</span> -->
          <!-- 待推荐修改放置在操作列  v-if="twoArrCludes(['ROLE_VENDOR'])"-->
          <span class="blue" v-if="twoArrCludes(['ROLE_VENDOR'])" src="javascript:;" @click="recommedResume(true, record)">{{$t('common.edit')}}</span>
          <template v-if="filterBtn(operateBtn, record, recordBtn).length">
            <span v-for="item in filterBtn(operateBtn, record, recordBtn)" :key="item.id" :class="item.class" @click="() => batchOperation(item.id, [record.id])">{{$t(item.name)}}</span>
          </template>
          <span v-else>&nbsp;</span>
        </p>
      </template>
      <!-- 邮箱直接开启邮件编辑 -->
      <template slot="email" slot-scope="text">
        <a :href="`mailto:${text}`" class="blue email">{{text}}</a>
      </template>
      <!-- 职位名称 军工点击职位名称，根据id筛选列表数据 猎头 vendorPartnerStatus === 'Y' 时，跳转到详细信息界面（职位名称字数超过33个做展示处理）-->
      <template slot="positionName" slot-scope="text, record">
        <a-tooltip :overlayStyle="{ maxWidth: '400px' }" v-if="text && text.length > 11">
          <template slot="title">
            <span style="white-space:wrap">{{text}}</span>
          </template>
          <p v-if="record.vendorPartnerStatus === 'Y'" class="blue cursor" @click="goPositionDetail(record)">{{text}}</p>
          <p v-else>{{text}}</p>
        </a-tooltip>
        <template v-else>
          <p v-if="record.vendorPartnerStatus === 'Y'" class="blue cursor" @click="goPositionDetail(record)">{{text}}</p>
          <p v-else>{{text}}</p>
        </template>
      </template>
      <!-- 动态模板返回的猎头渲染 -->
      <template v-for="item in fieldsTmp" :slot="item.key" slot-scope="text, record">
        <p :key="item.key">
          <a-tooltip v-if="text && text.length > 54">
            <template slot="title">
              {{text}}
            </template>
            <span @click="filterField(item, record)" :class="item.hasLink ? 'point': ''">{{text}}</span>
          </a-tooltip>
          <template v-else>
            <span @click="filterField(item, record)" :class="item.hasLink ? 'point': ''">{{text}}</span>
          </template>
        </p>
      </template>
      <template slot="status" slot-scope="text">
        <!-- REFUSE PASS -->
        <span class="statusBtn" :class="{blueBtn: text === 'RECOMMENDING', bgred: text === 'REFUSE', green: text === 'PASS'}" v-html="getStatusName(text)"></span>
      </template>
    </a-table>
    <!-- 待推荐列表推荐界面 -->
    <position-rec-resume :isPending="true" :positionInfo="positionInfo" :searchType="searchType" :visible="isshowRecom" :defaultBtn="2" @close="(data) => recommedRecom(false, data)" :positionId="positionId" :enterpriseId="enterpriseId"/>
    <!-- 军工没有编辑简历需要。 猎头编辑简历 -->
    <resume-edit :positionInfo="positionInfo" :visible="isshowResume" @close="(flag) => recommedResume(false, null, flag)" :id="id" :positionId="positionId" :enterpriseId="enterpriseId" :resumeData="resumeData" :resumeId="resumeData.id"/>
  </div>
</template>

<script>
import { mapState, mapMutations } from 'vuex'
// import { selectTreeList } from '@/api/employingUnit'
import TableOperate from '@/components/SearchList/TableOperate' // 搜索条件
import SearchFiled from '@/components/SearchList/SearchFiled' // 搜索后展示数据
import ResumeEdit from '@/components/resume/ResumeEdit'
import PositionRecResume from '@/components/position/PositionRecResume'
import { applicationList, applicationShowConfig, applicationOperator, recommendQueryConditions, resumeInfo, analyResult, deleteAnalyResult } from '@/api/resume'
import { filterBtn, recordBtn, twoArrCludes } from '@/util/roles'
const deliveryDateArr = [{ // 左上简历日期筛选
  id: 'all',
  name: 'searchList.dateText'
}, {
  id: '3D',
  name: 'searchList.3D'
}, {
  id: '1W',
  name: 'searchList.1W'
}, {
  id: '1M',
  name: 'searchList.1M'
}, {
  id: '6M',
  name: 'searchList.6M'
}]

const operateBtn = [{ // 军工简历操作按钮
  name: 'candidateApplication.pass',
  roles: ['ROLE_HRBP'],
  status: 'status',
  statusValN: ['PASS', 'REFUSE'],
  id: 'PASS'
}, {
  name: 'candidateApplication.reject',
  roles: ['ROLE_HRBP'],
  status: 'status',
  statusValN: ['PASS', 'REFUSE'],
  id: 'REFUSE'
// }, {
//   name: 'common.delete',
//   roles: ['ROLE_ADMIN'],
//   id: 'delete'
}]
export default {
  name: 'CandidateTable',
  components: { TableOperate, SearchFiled, ResumeEdit, PositionRecResume },
  // props: [ 'searchPositionId', 'dataList', 'searchType', 'isPending' ],
  props: {
    searchPositionId: { // 职位查询id
      type: String,
      require: false
    },
    dataList: { // 军工简历状态
      type: Array,
      require: false
    },
    searchType: { // 公司职位或者我的职位跳转过来
      type: String,
      require: false
    },
    vendorPartnerStatus: { // 公司职位或者我的职位跳转过来
      type: String,
      require: false
    },
    pendingStatus: { // 待推荐列表状态
      type: String,
      require: false
    },
    isPending: { // true为待推荐列表
      type: Boolean,
      require: false
    },
    noConditionIds: { // 条件搜索模板不需要的 表单元素 数组，有则进行筛选
      type: Array,
      require: false
    }
  },
  data () {
    return {
      operateBtnOP: null,
      positionInfo: {},
      id: '',
      columns: [
        {
          title: '姓名',
          dataIndex: 'name',
          key: 'name',
          scopedSlots: { customRender: 'name' }
        },
        {
          title: '邮箱',
          dataIndex: 'email',
          key: 'email',
          scopedSlots: { customRender: 'email' }
        },
        {
          title: '电话',
          dataIndex: 'mobile',
          key: 'mobile'
        },
        {
          title: '职位',
          dataIndex: 'positionName',
          key: 'positionName',
          scopedSlots: { customRender: 'positionName' }
        },
        {
          title: this.isPending ? '上传日期' : '推荐日期',
          dataIndex: 'deliverTime',
          key: this.isPending ? 'dateCreated' : 'deliverTime'
        }
      ],
      data: [],
      deliveryDateArr,
      operateBtn,
      searchListArr: [],
      unFieldList: [],
      unField: {}, // 列表点击后搜索数据
      selectedRowKeys: [],
      selectedRows: [],
      loading: false,
      deliverDate: '',
      resumeField: {}, // 搜索表单数据
      fieldsTmp: [],
      valueFileds: {},
      dateData: null,
      operator: '',
      isshowResume: false,
      isshowRecom: false,
      positionId: '',
      enterpriseId: '',
      resumeData: {},
      defaultSendData: {},
      pagination: {
        total: 0,
        simple: true,
        current: 1,
        pageSize: 15,
        onChange: this.changePage
      }
    }
  },
  created () {
    if (this.isPending) {
      this.columns.splice(3, 1)
      this.columns.push({
        title: '状态',
        dataIndex: 'pendingListStatus',
        key: 'pendingListStatus',
        scopedSlots: { customRender: 'pendingListStatus' }
      })
    }
    if (this.$route.query.operator) {
      this.operator = this.$route.query.operator
    }
    if (this.$route.query.deliverDate) {
      this.deliveryDateArr.forEach(item => {
        if (this.$route.query.deliverDate === item.id) {
          this.dateData = item
        }
      })
    }
    this.setshowConfig()
    this.initData()
  },
  computed: {
    ...mapState({
      showConfig: state => {
        return state.listDisplaySet.showConfig
      },
      userInfo: state => state.user.userInfo
    })
  },
  watch: {
    showConfig: {
      handler (val, oldVal) {
        this.pagination.pageSize = Number(val.max) || 15
        // 判定重复
        if (oldVal.fields && val.fields) {
          this.modifyShowConfig()
        }
      }
    },
    searchPositionId: {
      handler (val, oldVal) {
        if (val !== oldVal) {
          this.getListData()
        }
      }
    },
    pendingStatus: {
      handler (val, oldVal) {
        if (val !== oldVal) {
          this.pagination.current = 1
          this.getListData()
        }
      }
    },
    $route: {
      handler (val, oldVal) {
        if (val.query.operator !== oldVal.query.operator) {
          if (!val.query.operator) {
            this.operator = 'Delivered'
          } else {
            this.operator = val.query.operator === 'ALL' ? '' : val.query.operator
          }
          this.pagination.current = 1
          this.getListData()
        }
      }
    }
  },
  methods: {
    ...mapMutations('listDisplaySet', ['SET_FIELD']),
    twoArrCludes,
    filterBtn, // 军工使用操作按钮
    recordBtn, // 军工使用筛选操作按钮
    goPositionDetail (item) { // 猎头点击职位名称 后跳转到职位界面
      this.$router.push(`/position/positionEditing?positionId=${item.positionId}&searchType=${item.hrSiteType === 'VENDOR' ? 'PERSONAL' : 'COMPANY'}&enterpriseId=${item.enterpriseId}&sourcePid=${item.sourcePid}`)
    },
    getStatusName (text) { // 军工筛选候选人状态
      switch (text) {
        case 'RECOMMENDING':
          text = '已 推 荐'
          break
        case 'REFUSE':
          text = '&nbsp;&nbsp;拒&nbsp;&nbsp;绝&nbsp;&nbsp;'
          break
        case 'PASS':
          text = '&nbsp;&nbsp;通&nbsp;&nbsp;过&nbsp;&nbsp;'
          break
        default:
          break
      }
      return text
    },
    async getResumeData (record) { // 获取简历标准数据（猎头）
      let res = await resumeInfo({ id: record.id, positionId: record.positionId })
      if (res.code === 200) {
        // 处理表单数据并传递给页面
        this.resumeData = res.data
        this.isshowResume = true
      } else {
        this.$message.error(res.message)
      }
    },
    async delRecom (record) { // deleteAnalyResult 删除待推荐列表数据
      let res = await deleteAnalyResult({ analyzerRecordId: record.id })
      if (res.code === 200) {
        this.$emit('setData')
        this.$message.success(res.message)
      } else {
        this.$message.error(res.message)
      }
    },
    recommedRecom (flag, record) {
      if (record.type) {
        this.getListData()
      }
      this.callbackId = record.callbackId || ''
      this.positionId = record ? record.positionId : ''
      this.enterpriseId = record ? (record.enterpriseId || record.domain) : ''
      this.positionInfo = flag ? record : {}
      this.isshowRecom = flag
    },
    recommedResume (flag, record, type) { // 猎头编辑简历后操作按钮
      // this.resumeData = record
      if (record) {
        this.positionInfo = record
        this.positionId = record.positionId
        this.id = record.id
        this.enterpriseId = record.enterpriseId
        this.getResumeData(record)
      } else {
        this.positionId = ''
        this.enterpriseId = ''
        this.resumeData = {}
        this.positionInfo = {}
        this.isshowResume = flag
      }
      // }
      if (type) {
        this.getListData()
      }
    },
    initData () { // 初始化界面固定数据（显示设置，条件搜索模板）
      this.getSearchOptions()
    },
    async getSearchOptions (flag) { // 条件搜索模板
      let res = await recommendQueryConditions({ confingType: 'candidate' })
      if (res.code === 200) {
        this.searchListArr = []
        this.searchListArr = this.noConditionIds ? res.data.filter(item => !this.noConditionIds.includes(item.id)) : res.data
        this.searchListArr.some((element, index) => {
          if (element.type === 'treeSelect') { // 此处需要优化
            let arr = this.resizeTree(element.treeData, 'id')
            this.$set(this.searchListArr[index], 'treeData', arr)
          }
        })
        this.$nextTick(() => { // 页面搜索options加载完毕后处理数据
          if (flag && JSON.stringify(this.resumeField) !== '{}') {
            this.$refs.TableOperate && this.$refs.TableOperate.resetSearch() // 设置搜索项后重新根据表单获取列表数据
          } else if (!flag) {
            this.setInptData() // 设置初始化route值
          }
        })
      }
    },
    setRoute (field, title) {
      if (this.noConditionIds && this.noConditionIds.includes(field)) { // 获取不展示在条件筛选的数据，传递给列表获取接口
        this.$set(this.defaultSendData, field, this.$route.query[field])
        return
      }
      if (this.$route.query[field] && this.searchListArr.some(item => item.id === field)) { // 职位界面跳转过来
        this.$set(this.valueFileds, field, this.$route.query[field])
        return true
      } else if (this.$route.query[field]) {
        this.unFieldList.push({ id: field, name: title })
        this.$set(this.unField, field, this.$route.query[field])
      }
    },
    async setInptData () { // 设置初始化route值，设置完后组件会自动刷新当前页面列表数据
      if (!this.setRoute('candidateUserId', '候选人ID') &&
        !this.setRoute('positionId', '职位ID') &&
        !this.setRoute('categoryId', '职能类别ID') &&
        !this.setRoute('enterpriseId', '单位ID')) {
        this.$refs.TableOperate && this.$refs.TableOperate.resetSearch() // 设置搜索项后重新根据表单获取列表数据
      }
      // if ((this.$route.query.positionName || this.$route.query.enterpriseId) && !this.searchType && this.searchListArr.some(item => item.id === 'enterpriseId')) { // 职位界面跳转过来
      //   this.valueFileds = {
      //     positionName: this.$route.query.positionName,
      //     enterpriseId: this.$route.query.enterpriseId
      //   }
      // } else {
      //   this.unFieldList.push({ id: 'enterpriseId', name: '企业ID' })
      //   this.unFieldList.push({ id: 'positionName', name: '职位名称' })
      //   this.$set(this.unField, 'enterpriseId', this.$route.query.enterpriseId)
      //   this.$set(this.unField, 'positionName', this.$route.query.positionName)
      // }
    },
    // controlData (data) {
    //   return data.map(item => {
    //     return { id: item.id || item.userId, name: item.name }
    //   })
    // },
    filterField (item, record) { // 根据hasLink判定当前列数据能否点击，点击后设置筛选条件
      if (!item.hasLink) return
      this.pagination.current = 1
      if (this.searchListArr.some(element => {
        return element.id === item.path
      })) {
        this.valueFileds = {}
        this.$set(this.valueFileds, item.path, eval('record.' + item.path))
      } else {
        if (!this.unFieldList.some(val => val.id === item.key)) {
          this.unFieldList.push({ id: item.key, name: item.title })
        }
        this.$set(this.unField, item.key, eval('record.' + item.key))
        this.getListData()
      }
    },
    closeOneField (id) { // x掉搜索标签
      if (this.unField[id]) {
        this.$set(this.unField, id, '')
        this.getListData()
      } else {
        this.valueFileds = {}
        this.$set(this.valueFileds, id, '')
      }
    },
    setPosition (positionId) { // 点击表格职位设置 条件搜索模块条件，并刷新 表格数据 （只军工使用）
      if (this.searchListArr.some(element => {
        return element.id === 'positionId'
      })) {
        this.valueFileds = {
          positionId
        }
        this.$set(this.valueFileds, 'positionId', positionId)
      } else {
        if (!this.unFieldList.some(val => val.id === 'positionId')) {
          this.unFieldList.push({ id: 'positionId', name: '职位ID' })
        }
        this.$set(this.unField, 'positionId', positionId)
        this.getListData()
      }
    },
    onSelectChange (selectedRowKeys, selectedRows) { // 只军工 选择候选人checkbox后做批量操作处理
      this.selectedRowKeys = selectedRowKeys
      this.selectedRows = selectedRows
      this.operateBtnOP = this.filterBtn(this.operateBtn, selectedRows, this.recordBtn)
    },
    // deleteData (ids) {
    //   ids = ids.split(',')
    //   let Tmp = this.data.filter(item => {
    //     return !ids.includes(item.id)
    //   })
    //   if (Tmp.length === 0) {
    //     this.getListData()
    //   } else {
    //     this.data = Tmp
    //   }
    // },
    async batchOperation (status, id) { // 只军工操作候选人 待定、合适、不合适分发的方法
      this.loading = true
      let params = id.map(item => {
        return { id: item, status }
      })
      let res = await applicationOperator(params)
      if (res.code === 200) {
        this.getListData()
        this.$emit('getCard')
        this.$message.success(res.message)
      } else {
        this.$message.error(res.message)
      }
      this.loading = false
    },
    resizeTree (arr, field = 'id', key = 0) { // 树形搜索结构处理
      if (!Array.isArray(arr)) return
      return arr.map((item, index) => {
        let treekey = `${key}-${index}`
        return { title: item.name, value: item[field], key: item[field], id: item[field], children: this.resizeTree(item.children, field, treekey) }
      })
    },
    setshowConfigData (data) {
      this.pagination.pageSize = data.max
      this.fieldsTmp = []
      this.unFieldList = []
      data.fields.forEach(item => {
        if (item.checked) {
          if (item.key === 'operatorStatus') {
            this.fieldsTmp.push({ title: item.value, dataIndex: item.key, key: item.key, scopedSlots: { customRender: item.key }, hasLink: item.hasLink })
          } else {
            this.fieldsTmp.push({ title: item.value, dataIndex: item.key, key: item.key, scopedSlots: { customRender: item.key }, hasLink: item.hasLink, path: item.path })
          }
          this.unFieldList.push({ id: item.path, name: item.value })
        }
      })
      this.SET_FIELD(data)
    },
    async setshowConfig () { // 设置显示设置，及界面列头文字展示
      if (!this.isPending) {
        let candidateShowConfig = localStorage.getItem('candidateShowConfig' + this.userInfo.id) // 获取缓存数据，有的话不进行请求
        if (candidateShowConfig) {
          this.$nextTick(() => {
            this.setshowConfigData(JSON.parse(candidateShowConfig))
          })
          return
        }
        let res = await applicationShowConfig()
        if (res.code === 200) {
          if (res.data && res.data.fields) {
            localStorage.setItem('candidateShowConfig' + this.userInfo.id, JSON.stringify(res.data)) // 缓存没有数据，请求回来后存储到缓存
            this.setshowConfigData(res.data)
          }
        } else {
          this.$message.error(res.message)
        }
      }
      // if (!this.$route.query.positionId && !this.$route.query.candidateUserId && !this.$route.query.enterpriseId && !this.$route.query.categoryId) {
      //   this.getListData()
      // }
    },
    async modifyShowConfig () { // 改变显示设置后操作数据
      // let fields = this.showConfig.fields.filter(item => item.checked)
      localStorage.setItem('candidateShowConfig' + this.userInfo.id, JSON.stringify(this.showConfig)) // 更新缓存数据
      // let res = await addOrModifyShowConfig(this.showConfig)
      // if (res.code === 200) {
      this.fieldsTmp = []
      this.showConfig.fields.forEach(item => {
        if (item.checked) {
          if (item.key === 'operatorStatus') {
            this.fieldsTmp.push({ title: item.value, dataIndex: item.key, key: item.key, scopedSlots: { customRender: item.key }, hasLink: item.hasLink })
          } else {
            this.fieldsTmp.push({ title: item.value, dataIndex: item.key, key: item.key, scopedSlots: { customRender: item.key }, hasLink: item.hasLink, path: item.path })
          }
          this.unFieldList.push({ id: item.path, name: item.value })
        }
      })
      this.getSearchOptions(true)
      //   if (!this.noConditionIds) {
      //     this.$message.success(res.message)
      //   }
      // } else {
      //   this.$message.error(res.message)
      // }
    },
    clearSearch () { // 点击清除 清空条件搜索
      this.unField = {}
      this.$refs.TableOperate.clearSearch()
    },
    chooseDeliveryDate (item) { // 选择左上时间
      this.pagination.current = 1
      this.deliverDate = item.id === 'all' ? '' : item.id
      this.getListData()
    },
    searchFormValue (item) { // 触发条件搜索
      item.gender = item.gender === 'all' ? '' : item.gender
      this.resumeField = item
      this.pagination.current = 1
      this.getListData()
    },
    editResume (record) { // 跳转到候选人详细信息列表页面，根据不同参数展示不同平台详细信息
      let list = this.data.map((item, index) => item.userId)
      let deliveryList = this.data.map((item, index) => item.id)
      let positionList = this.data.map((item, index) => item.positionId)
      let enterpriseIdList = this.data.map((item, index) => item.enterpriseId)
      let obj = {
        positionList,
        list,
        deliveryList,
        path: this.$route.path,
        fullPath: this.$route.fullPath,
        enterpriseIdList
      }
      sessionStorage.setItem('resumeList', JSON.stringify(obj))
      this.$router.push(`/resume/resumeView?id=${record.id}&positionId=${record.positionId}&enterpriseId=${record.enterpriseId}`)
    },
    changePage (current, pageSize) { // 切换页签时数据
      this.$set(this.pagination, 'current', current)
      this.getListData()
    },
    getListData () { // 获取当前页面简历信息列表
      if (this.isPending) { // 猎头待推荐列表
        this.getPendingList()
      } else { // 所有其他情况列表
        this.getApplicationList()
      }
    },
    async getPendingList () {
      this.selectedRowKeys = []
      let params = {
        max: this.pagination.pageSize,
        offset: (this.pagination.current - 1) * this.pagination.pageSize,
        queryFilter: {
          // operator: this.operator,
          deliverDate: this.deliverDate,
          ...this.unField,
          ...this.resumeField,
          ...this.defaultSendData
        }
      }
      if (this.searchPositionId) {
        params.searchType = this.searchType
        params.queryFilter.positionId = this.searchPositionId
      }
      params.queryFilter.status = this.pendingStatus === 'ALL' ? '' : this.pendingStatus
      let res = await analyResult(params)
      if (res.code === 200) {
        this.data = res.data.list.map(item => {
          if (item.resume) {
            return { ...item.resume.basic, ...item }
          } else {
            return item
          }
        })
        this.$set(this.pagination, 'total', res.data.filterCount)
        this.$emit('pendingCount', res.data)
      } else {
        this.$message.error(res.message)
      }
    },
    async getApplicationList () { // isPending
      this.loading = true
      this.selectedRowKeys = []
      let params = {
        max: this.pagination.pageSize,
        offset: (this.pagination.current - 1) * this.pagination.pageSize,
        queryFilter: {
          // operator: this.operator,
          deliverDate: this.deliverDate,
          name: this.resumeField.keyword,
          ...this.unField,
          ...this.resumeField,
          ...this.defaultSendData
        }
      }
      if (this.searchPositionId) {
        params.searchType = this.searchType
        params.queryFilter.positionId = this.searchPositionId
      }
      params.queryFilter.status = this.operator
      let res = await applicationList(params)
      if (res.code === 200) {
        this.data = res.data.items
        this.$set(this.pagination, 'total', res.data.totalCount)
        this.$emit('count', res.data.totalCount)
      } else {
        this.$message.error(res.message)
      }
      this.loading = false
    },
    setRowClassName (record, index) {
      return index % 2 === 0 ? 'grey' : ''
    }
  },
  beforeDestroy () { // 销毁时设置 勾选的field 条件
    this.SET_FIELD({})
  }
}
</script>

<style lang="stylus" scoped>
@import '../../styles/var.styl'
.CandidateTable
// .ant-table-tbody > tr > td
  background #fff
  .statusBtn
    display inline-block
    // width 60px
    border-radius: 15px;
    padding: 2px 8px;
    height: 24px;
    color #fff
    text-align center
    line-height 20px
    &.greyBtn
      background #e6e6e6
    &.blueBtn
      background var(--blue-500)
  // 表格头部公共写法
  :global(.ant-table-title)
    padding 0
  :global(.ant-table-thead th)
    white-space nowrap
    background none
    padding 0
  :global(.ant-table-thead .ant-table-header-column)
    display inline-block
    width calc(100% - 16px)
    padding 5px 8px
    margin 5px 8px
    border-right 1px solid borderColor
  :global(.ant-table-thead th:first-child .ant-table-header-column)
  :global(.ant-table-thead th:last-child .ant-table-header-column)
    border-right none
  :global(.ant-table-tbody >tr >td)
    white-space nowrap
    padding 7px 16px
    vertical-align top
    >p
      white-space normal
      width 256px
      max-width 256px
      overflow : hidden;
      text-overflow: ellipsis;
      display -webkit-box
      -webkit-line-clamp 1 // 规定几行显示省略号
      -webkit-box-orient vertical
  :global(.grey)
    background var(--light-grey)
  .updateText
    cursor pointer
    margin 0
    font-weight 600
  .update
    // visibility hidden
    margin 6px 0 0
    span
      display none
      cursor pointer
      // border-right 1px solid borderColor
      padding 0 0 0 4px
      color var(--blue-500)
      &:first-child
        padding-left 0
      &:last-child
        color errorColor
        &:after
          height 0
      &:after
        content ''
        vertical-align middle
        background borderColor
        display inline-block
        height 14px
        width 1px
        margin-left 4px
      &.blue
        color var(--blue-500)
  :global(.ant-table-row)
    margin 0 12px
  .status
    padding 0 6px
    color #fff
    // border-radius 4px
  .email
    color inherit
  .bgBlue
    background var(--blue-500)
  .bgred
    background errorColor
  .grey
    background textDisable
  .red
    color errorColor
  .blue:hover
    color var(--blue-500)
  .green
    background lightGreen
    color #fff
    border none
  .green_text
    color lightGreen
  .orange
    color orange!important
:global(.ant-table-row:hover)
  .blue_hover
    color var(--blue-500)
  .update
    >span
      // visibility visible
      display inline-block
.point
  cursor pointer
  &:hover
    color var(--blue-500)
</style>
